/*
 *   判断配置文件运行环境
 *   浏览器环境，根据 cookie: name="CURRENT_ENV" 判断
 *   node 环境，process.env.NODE_ENV 判断
 */
var global_obj_urls = {},
    system_obj_urls = {},
    env = typeof window !== 'undefined' ? (function () {
    // 获取cookie
    function getCookie(name) {
        var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
        if (arr = document.cookie.match(reg)) {
            return unescape(arr[2]);
        } else {
            return null;
        }
    }

    return (getCookie('CURRENT_ENV') || 'production')

})() : process.env.NODE_ENV;

switch (env){
    case 'dev':  // 开发环境
        global_obj_urls = {
            baseUrl: 'http://192.168.2.203:5790'
        };
        system_obj_urls = {
            'yu': 'http://192.168.70.220:3001',
            'college': 'http://192.168.70.220:3002',
            'pin': 'http://192.168.70.220:3003',
            'pin_find': 'http://192.168.3.95:3003',
            'pai': '//'
        };
        break;
    case 'test': // 测试环境
        global_obj_urls = {
            baseUrl: 'http://192.168.2.203:5791'
        };
        system_obj_urls = {
            'yu': 'http://192.168.2.208:3080',
            'college': 'http://192.168.2.208:3081',
            'pin': 'http://192.168.2.208:3082',
            'pin_find': 'http://192.168.2.208:3083',
            'pai': 'http://192.168.2.208:3001'
        };
        break;
    case 'production': // 线上环境
        global_obj_urls = {
            baseUrl: 'http://pangu1.lan-bridge.cn:5791',
            online_domain: '51yuyan.com'
        };
        system_obj_urls = {
            'yu': 'http://www.51yuyan.com',
            'college': 'http://college.51yuyan.com',
            'pin': 'http://pin.51yuyan.com',
            'pin_find': 'http://hrpin.51yuyan.com',
            'pai': 'http://pai.51yuyan.com'
        };
        break
}

if(typeof window === 'undefined'){
    global_obj_urls.system_obj_urls = system_obj_urls
}

module.exports = global_obj_urls;